<div class="row">
	<div class="col-md-12">
		<form id="userEditForm" action="${request.contextPath}/system/authority/user/update" method="post" onsubmit="return false">
			<input type="hidden" id="id" name="id" value="${sysUser.id}">
			<div class="box-body">
				<div class="form-group">
					<label id="userLoginnameLabel">登录名</label>
					<input type="text" class="form-control" name="loginname" id="userLoginname" value="${sysUser.loginname}"  placeholder="输入登录名...">
				</div>
				<div class="form-group">
					<label id="userNicknameLabel">昵称</label>
					<input type="text" class="form-control" name="nickname" id="userNickname" value="${sysUser.nickname}" placeholder="输入名称...">
				</div>
				<div class="form-group">
					<label id="userSignatureLabel">个性签名</label>
					<input type="text" class="form-control" name="signature" id="userSignature" value="${sysUser.signature}" placeholder="输入参数值...">
				</div>
				<div class="form-group">
					<label id="userRemarkLabel">备注</label>
					<input type="text" class="form-control" name="remark" id="userRemark"  value="${sysUser.remark}" placeholder="输入备注...">
				</div>
				<div class="error-message text-center" >
					<span class="error-icon"></span>
					<span id="error-msg" class="error-msg" ></span>
				</div>
             </div>
			<div class="box-footer">
				<div class="pull-right">
               		<button type="submit" class="btn btn-primary btn-sm"><i class="fa fa-paste"></i> 更新</button>
               		<button type="button" class="btn btn-default btn-sm" data-dismiss="modal"><i class="fa fa-close"></i> 关闭</button>
				</div>
          	</div>
		</form>
	</div>
</div>
<script type="text/javascript">
function ajaxSubmit(form) {
	
	var $form = $(form);
	
	if ($form.length === 1 && $form.validate()) {
		$.post(form.action, $form.serialize(),function(result) {
			if (result.success) {
				$("#lgModal").modal('hide');
	        	alertMsg(result.message,"success");
	        	userReload();
			} else {
				$form.find(".error-msg").show();
				$form.find(".error-msg").html(result.message);
			}
		}, 'json');
	}
}

$(function() {
	$userEditForm = $("#userEditForm");
	$userEditForm.validate({
		rules: {
			nickname: {
				required: true
			}
		},
		messages: {
			nickname:{
				required:"昵称不能为空！"
			}
		},
		submitHandler:ajaxSubmit,
		errorLabelContainer:".error-msg",
		wrapper:"li",
		showErrors:function(errorMap,errorList) {
			if(errorList.length>0){
				$userEditForm.find(".error-msg").html(errorList[0].message);
			}else{
				$userEditForm.find(".error-msg").html("");
			}
		},
		onkeyup: false
	});
});
</script>